﻿<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link href="demo.css" rel="stylesheet" type="text/css"/>
    <script src="../../static/scripts/boot.js" type="text/javascript"></script>
</head>
<body>
<div class="mini-splitter" style="width:100%;height:100%;">
    <div size="200px;" showCollapseButton="true" style="padding:5px;">
        <div region="west" title="在线演示" showHeader="true" bodyStyle="padding-left:1px;" showSplitIcon="true" width="230" minWidth="100" maxWidth="350">
            <ul id="demoTree" class="mini-tree" showTreeIcon="true" style="width:100%;height:100%;"
                enableHotTrack="true" onbeforeexpand="onBeforeExpand" >
                <li><a href="overview.html" target="main">Overview</a></li>
                <li>
                    <span expanded="false">控件列表</span>
                    <ul>
                        <li><a onclick="formDesign.exec('text');" target="main">MessageBox</a></li>
                        <li><a href="iconcls.html" target="main">iconCls</a></li>
                        <li>
                            <span expanded="false">表单控件</span>
                            <ul>
                                <li><a href="progressbar/progressbar.html" target="main" title="进度条">ProgressBar <span style="color:Red;">New!</span></a></li>
                                <li><a href="form/labelfield.html" target="main" >LabelField <span style="color:Red;">New!</span></a></li>
                                <li><a href="databinding/databinding.html" target="main" >DataBinding <span style="color:Red;">New!</span></a></li>
                                <li><a href="fontcss/fontcss.html" target="main" title="自定义字体大小">Diy FontSize <span style="color:Red;">New!</span></a></li>
                                <li><a href="form/diysize.html" target="main" title="自定义控件高度">Diy Size <span style="color:Red;">New!</span></a></li>
                                <li><a href="form/aslabel.html" target="main" title="文本显示输入框">AsLabel <span style="color:Red;">New!</span></a></li>
                                <li>
                                    <span value="form" expanded="false">Form</span>
                                    <ul>
                                        <li><a href="form/form.html" target="main" title="按钮">Form</a></li>
                                        <li><a href="form/rules.html" target="main" title="验证规则">Validation Rules <span style="color:Red;">New!</span></a></li>
                                        <li><a href="form/validation.html" target="main" title="数据验证">Validation</a></li>
                                        <li><a href="form/validLabel.html" target="main" title="文本显示">Validation Label</a></li>
                                        <li><a href="form/validGroup.html" target="main" title="组合验证">Validation Summary</a></li>
                                        <li><a href="form/validWindow.html" target="main" title="弹出框验证">Validation Window</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <span value="button" expanded="false">Button</span>
                                    <ul>
                                        <li><a href="toolbar/toolbaroverflow.html" target="main" title="下拉弹出层工具栏">ToolBarOverflow<span style="color:Red;">New!</span></a></li>
                                        <li><a href="button/button_iconfont.html" target="main" title="文字图标">文字图标<span style="color:Red;">New!</span></a></li>
                                        <li><a href="button/button_img.html" target="main" title="图片图标">图片图标<span style="color:Red;">New!</span></a></li>
                                        <li><a href="button/button_bootstrap.html" target="main" title="Bootstrap风格按钮">Button ( Bootstrap )<span style="color:Red;">New!</span></a></li>
                                        <li><a href="button/button.html" target="main" title="按钮">Button</a></li>
                                        <li><a href="button/menubutton.html" target="main" title="下拉菜单按钮">MenuButton</a></li>
                                        <li><a href="button/radiobutton.html" target="main" title="按钮单选组">RadioButton</a></li>
                                        <li><a href="toolbar/toolbar.html" target="main" title="工具栏按钮">Toolbar</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <span value="tooltip" expanded="false">TooTtip <span style="color:Red;">New!</span></span>
                                    <ul>
                                        <li><a href="tooltip/tooltip.html" target="main" title="提示框">ToolTip</a></li>
                                        <li><a href="tooltip/ajaxload.html" target="main" title="ajax加载提示">Ajax Load</a></li>
                                        <li><a href="tooltip/grid.html" target="main" title="单元格加载提示">Grid Tooltip</a></li>
                                        <li><a href="tooltip/form.html" target="main" title="表单验证错误提示">Form Tooltip</a></li>
                                    </ul>
                                </li>
                                <li><a href="textboxlist/textboxlist.html" target="main" title="多选输入框">TextBoxList </a></li>
                                <li><a href="textboxlist/textboxlist_input.html" target="main" title="输入模式（不选择））">TextBoxList InputMode <span style="color:Red;">New!</span></a></li>
                                <li><a href="autocomplete/autocomplete.html" target="main" title="文本自动填充框">AutoComplete </a></li>
                                <li><a href="treeselect/treeselect.html" target="main" title="树形下拉选择框" >TreeSelect</a></li>
                                <li><a href="treeselect/lazy.html" target="main" title="懒加载树形下拉框" >TreeSelect(Lazy) <span style="color:Red;">New!</span></a></li>
                                <li><a href="combobox/combobox.html" target="main" title="下拉选择框">ComboBox</a></li>
                                <li><a href="combobox/linkage-combo.html" target="main" title="联动选择ComboBox">ComboBox(联动选择)</a></li>
                                <li><a href="combobox/drawcell.html" target="main" title="下拉选择框">ComboBox(Draw item)</a></li>
                                <li><a href="datepicker/datepicker.html" target="main" title="日期选择框">DatePicker</a></li>
                                <!--<li><a href="datepickerx/index.html" target="main" title="跨页面日期选择框">DatePickerx <span style="color:Red;">New!</span></a></li>-->
                                <li><a href="monthpicker/monthpicker.html" target="main" title="年月选择框">MonthPicker</a></li>
                                <li><a href="lookup/lookup.html" target="main" title="下拉搜索框" >Lookup <span style="color:Red;">New!</span></a></li>

                                <li value="checkbox"><a href="checkbox/checkbox.html" target="main" title="复选框">CheckBox</a></li>


                                <li><a href="listbox/listbox.html" target="main" title="列表框">ListBox</a></li>
                                <li><a href="listbox/moveitems.html" target="main" title="在两个列表框之间选中移动项">ListBox(Move Items)</a></li>

                                <li><a href="checkboxlist/checkboxlist.html" target="main" title="多选框组">CheckBoxList</a></li>

                                <li><a href="radiobuttonlist/radiobuttonlist.html" target="main" title="单选框组">RadioButtonList</a></li>


                                <li><a href="calendar/calendar.html" target="main" title="日期选择器">Calendar</a></li>

                                <li><a href="buttonedit/buttonedit.html" target="main" title="按钮输入框">ButtonEdit</a></li>
                                <li><a href="buttonedit/buttonedit_buttons.html" target="main" title="自定义按钮">ButtonEdit Buttons<span style="color:Red;">New!</span></a></li>
                                <li><a href="buttonedit/buttonedit_height.html" target="main" title="自定义输入框高度">ButtonEdit Height<span style="color:Red;">New!</span></a></li>
                                <li><a href="filteredit/filteredit.html" target="main" title="过滤输入框">FilterEdit <span style="color:Red;">New!</span></a></li>

                                <li><a href="textbox/textbox.html" target="main" title="单行输入框">TextBox</a></li>
                                <li><a href="textbox/textbox.html" target="main" title="密码输入框">Password</a></li>
                                <li><a href="textbox/textbox.html" target="main" title="多行输入框">TextArea</a></li>

                                <li><a href="spinner/spinner.html" target="main" title="数字输入框">Spinner</a></li>

                                <li><a href="timespinner/timespinner.html" target="main" title="时间输入框">TimeSpinner</a></li>

                                <li><a href="fileupload/htmlfile_ajax.html" target="main" title="Ajax文件上传选择框">AjaxFileUpload <span style="color:Red;">New!</span></a></li>
                                <li><a href="fileupload/htmlfile.html" target="main" title="文件上传选择框(HTML版本)">HtmlFile</a></li>
                                <li><a href="fileupload/fileupload.html" target="main" title="文件上传选择框(FLASH版本)">FileUpload</a></li>

                                <li><a href="multiupload/multiupload.html" target="main" title="多选文件上传">MultiUpload <span style="color:Red;">New!</span></a></li>
                                <li><a href="multiupload/multiupload_openwindow.html" target="main" title="多选文件上传弹出框">MultiUpload Window <span style="color:Red;">New!</span></a></li>

                            </ul>
                        </li>
                        <li>
                            <span expanded="false">表格控件</span>
                            <ul>
                                <li><a href="datagrid/cardview.html" target="main">CardView <span style="color:Red;">New!</span></a></li>
                                <li><a href="datagrid/jsonp.html" target="main">JsonP </a></li>
                                <li><a href="datagrid/exceledit.html" target="main">Excel EditMode</a></li>
                                <li><a href="datagrid/copyexcel.html" target="main">Copy Excel </a></li>

                                <li><a href="datagrid/datagrid.html" target="main">DataGrid</a></li>
                                <li><a href="datagrid/cellvalidation.html" target="main" >CellValidation  </a></li>
                                <li><a href="databinding/databinding.html" target="main" >DataBinding </a></li>
                                <li><a href="datagrid/pager.html" target="main">Pagination</a></li>
                                <li><a href="datagrid/diypager.html" target="main">Diy Pagination </a></li>
                                <li><a href="datagrid/pager_client.html" target="main">Client Pagination </a></li>
                                <li><a href="datagrid/pagerbuttons.html" target="main">Pager Buttons </a></li>
                                <li><a href="datagrid/fitsize.html" target="_blank">Fit Size</a></li>
                                <li><a href="datagrid/export.html" target="main">Export Excel</a></li>
                                <li>
                                    <span expanded="false">Grid Rows</span>
                                    <ul>
                                        <li><a href="datagrid/filter_header.html" target="main">Header Filter <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/filter_client.html" target="main">Filter ( Client ) </a></li>
                                        <li><a href="datagrid/filter.html" target="main">Filter ( Server )</a></li>
                                        <li><a href="datagrid/summary.html" target="main">Data Summary</a></li>
                                        <li><a href="datagrid/multiselect.html" target="main">Multi Select</a></li>
                                        <li><a href="datagrid/pageselection.html" target="main">PageSelection <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/columnsmenu.html" target="main">ColumnsMenu <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/diycolumnsmenu.html" target="main">Diy ColumnsMenu <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/diycolumnscontextmenu.html" target="main">Diy ColumnsContextMenu <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/contextmenu.html" target="main">ContextMenu</a></li>
                                        <li><a href="datagrid/alternating.html" target="main">Alternating Row Style</a></li>
                                        <li><a href="datagrid/gridlines.html" target="main">Grid Lines</a></li>
                                        <li><a href="datagrid/rowdetail.html" target="main">Row Detail</a></li>
                                        <!--<li><a href="datagrid/preview.html" target="main">Preview Row</a></li>-->
                                        <li><a href="datagrid/rowtemplate.html" target="main">Row Template</a></li>
                                        <li><a href="datagrid/moveitems.html" target="main">MoveItems </a></li>
                                        <li><a href="datagrid/moveitems_copy.html" target="main">MoveItems Copy </a></li>
                                        <li><a href="datagrid/moverow.html" target="main">Move Up/Down </a></li>
                                    </ul>
                                </li>
                                <li>
                                    <span expanded="false">Grid Columns</span>
                                    <ul>
                                        <li><a href="datagrid/setcolumns.html" target="main">Dynamic Columns <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/fixedcolumns.html" target="main">Fixed Columns</a></li>
                                        <li><a href="datagrid/columngroup.html" target="main">Column Group</a></li>
                                        <li><a href="datagrid/drawcell.html" target="main">Draw Cell</a></li>
                                        <li><a href="datagrid/drawcell2.html" target="main" >Draw Cell 2</a></li>
                                        <li><a href="datagrid/currencyformatter.html" target="main" >CurrencyFormatter <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/hidecolumn.html" target="main">Show/Hide Column</a></li>
                                        <li><a href="datagrid/fixcolumnwidth.html" target="main">Fix Column Width</a></li>
                                        <li><a href="datagrid/fitcolumnwidth.html" target="main">Fit Column Width</a></li>
                                        <li><a href="datagrid/mergecells.html" target="main">MergeCells </a></li>
                                        <li><a href="datagrid/mergecolumns.html" target="main">MergeColumns <span style="color:Red;">New!</span></a></li>
                                    </ul>
                                </li>
                                <li>
                                    <span expanded="false">Grid Edit</span>
                                    <ul>
                                        <li><a href="datagrid/celledit.html" target="main">CellEdit <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/rowedit.html" target="main">RowEdit</a></li>
                                        <li><a href="datagrid/editform.html" target="main">EditForm</a></li>
                                        <li><a href="datagrid/popupeditform.html" target="main">Popup EditForm</a></li>
                                        <li><a href="datagrid/editable.html" target="main">Cell Editable <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/editable-rowedit.html" target="main">RowEdit Editable <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/celllinkedit.html" target="main">CellLinkEdit <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/celllinkedit_local.html" target="main">CellLinkEdit_Local <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/celllinkedit2.html" target="main">RowLinkEdit <span style="color:Red;">New!</span></a></li>

                                        <li><a href="datagrid/rowedit_lookup.html" target="main">Lookup Editor</a></li>
                                        <li><a href="datagrid/rowedit_openwindow.html" target="main">OpenWindow Editor</a></li>
                                        <li><a href="datagrid/rowedit_openpage.html" target="main">OpenPage Editor</a></li>
                                        <li><a href="datagrid/rowedit_textboxlist.html" target="main">TextBoxList Editor</a></li>
                                        <li><a href="datagrid/rowedit_autocomplete.html" target="main">AutoComplete Editor</a></li>
                                        <li><a href="datagrid/rowedit_treeselect.html" target="main">TreeSelect Editor</a></li>
                                        <li><a href="datagrid/staticedit.html" target="main">StaticEdit </a></li>

                                    </ul>
                                </li>
                                <li>
                                    <span expanded="false">Sort & Group <span style="color:Red;">New!</span></span>
                                    <ul>
                                        <li><a href="datagrid/sorting.html" target="main">Sorting (Server)</a></li>
                                        <li><a href="datagrid/sorting_client.html" target="main">Sorting (Client) </a></li>
                                        <li><a href="datagrid/sorting_multi.html" target="main">Multi Sorting <span style="color:Red;">New!</span></a></li>
                                        <li><a href="datagrid/grouping.html" target="main">Grouping </a></li>
                                    </ul>
                                </li>
                                <li>
                                    <span expanded="false">Master-Detail</span>
                                    <ul>
                                        <li><a href="datagrid/detailform.html" target="main">Detail Form</a></li>
                                        <li><a href="datagrid/detailgrid.html" target="main">Detail Grid</a></li>
                                        <li><a href="datagrid/detailtabs.html" target="main">Detail Tabs</a></li>
                                        <li><a href="datagrid/inline_detailform.html" target="main">Inline Form</a></li>
                                        <li><a href="datagrid/inline_detailgrid.html" target="main">Inline Grid</a></li>
                                        <li><a href="datagrid/inline_detailtabs.html" target="main">Inline Tabs</a></li>
                                        <li><a href="datagrid/popupeditform.html" target="main">Popup Form</a></li>
                                    </ul>
                                </li>
                            </ul>
                        </li>






                    </ul>
                </li>

            </ul>
        </div>

    </div>
    <div showCollapseButton="true">
        <div class="span10">
            <script id="formEditor" type="text/plain" style="width:100%;height: 100%;"></script>
        </div>
    </div>
</div>
<script type="text/javascript" charset="utf-8" src="../../static/scripts/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../../../ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../../../ueditor/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="../../../../../ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" charset="utf-8" src="../../static/ueditor/formdesign/formdesign.v4.js"></script>
<!-- script start-->
<script type="text/javascript">
    mini.parse();
    function onBeforeExpand(e) {
        var tree = e.sender;
        var nowNode = e.node;
        var level = tree.getLevel(nowNode);

        var root = tree.getRootNode();
        tree.cascadeChild(root, function (node) {
            if (tree.isExpandedNode(node)) {
                var level2 = tree.getLevel(node);
                if (node != nowNode && !tree.isAncestor(node, nowNode) && level == level2) {
                    tree.collapseNode(node, true);
                }
            }
        });

    }
    var formEditor = UE.getEditor('formEditor',{
        toolleipi:true,//是否显示，设计器的 toolbars
        textarea: 'design_content',
        //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
        toolbars:[[
            'fullscreen', 'source', '|', 'undo', 'redo', '|','bold', 'italic', 'underline', 'fontborder', 'strikethrough',  'removeformat', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist','|', 'fontfamily', 'fontsize', '|', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',  'link', 'unlink',  '|',  'horizontal',  'spechars',  'wordimage', '|', 'inserttable', 'deletetable',  'mergecells',
            'insertrow', //前插入行
            'insertcol', //前插入列
            'mergeright', //右合并单元格
            'mergedown', //下合并单元格
            'deleterow', //删除行
            'deletecol', //删除列
            'splittorows', //拆分成行
            'splittocols', //拆分成列
            'splittocells', //完全拆分单元格
            'deletecaption', //删除表格标题
            'inserttitle', //插入标题
            'mergecells', //合并多个单元格
            'deletetable', //删除表格
            'cleardoc', //清空文档
            'preview', //预览
            'insertparagraphbeforetable','splittocells']],
        //focus时自动清空初始化时的内容
        //autoClearinitialContent:true,
        //关闭字数统计
        wordCount:false,
        //关闭elementPath
        elementPathEnabled:false
    });
    var formDesign = {
        /*执行控件*/
        exec : function (method) {
            formEditor.execCommand(method);
        },
        /*
         Javascript 解析表单
         template 表单设计器里的Html内容
         fields 字段总数
         */
        parse_form:function(template,fields)
        {
            //正则  radios|checkboxs|select 匹配的边界 |--|  因为当使用 {} 时js报错 (plugins|fieldname|fieldflow)
            var preg =  /(\|-<span(((?!<span).)*plugins=\"(radios|checkboxs|select)\".*?)>(.*?)<\/span>-\||<(img|input|textarea|select).*?(<\/select>|<\/textarea>|\/>))/gi,preg_attr =/(\w+)=\"(.?|.+?)\"/gi,preg_group =/<input.*?\/>/gi;
            if(!fields) fields = 0;

            var template_parse = template,template_data = new Array(),add_fields=new Object(),checkboxs=0;

            var pno = 0;
            template.replace(preg, function(plugin,p1,p2,p3,p4,p5,p6){
                var parse_attr = new Array(),attr_arr_all = new Object(),name = '', select_dot = '' , is_new=false;
                var p0 = plugin;
                var tag = p6 ? p6 : p4;
                //alert(tag + " \n- t1 - "+p1 +" \n-2- " +p2+" \n-3- " +p3+" \n-4- " +p4+" \n-5- " +p5+" \n-6- " +p6);

                if(tag == 'radios' || tag == 'checkboxs')
                {
                    plugin = p2;
                }else if(tag == 'select')
                {
                    plugin = plugin.replace('|-','');
                    plugin = plugin.replace('-|','');
                }
                plugin.replace(preg_attr, function(str0,attr,val) {
                    if(attr=='name')
                    {
                        if(val=='NEWFIELD')
                        {
                            is_new=true;
                            fields++;
                            val = 'data_'+fields;
                        }
                        name = val;
                    }

                    if(tag=='select' && attr=='value')
                    {
                        if(!attr_arr_all[attr]) attr_arr_all[attr] = '';
                        attr_arr_all[attr] += select_dot + val;
                        select_dot = ',';
                    }else
                    {
                        attr_arr_all[attr] = val;
                    }
                    var oField = new Object();
                    oField[attr] = val;
                    parse_attr.push(oField);
                })
                /*alert(JSON.stringify(parse_attr));return;*/
                if(tag =='checkboxs') /*复选组  多个字段 */
                {
                    plugin = p0;
                    plugin = plugin.replace('|-','');
                    plugin = plugin.replace('-|','');
                    var name = 'checkboxs_'+checkboxs;
                    attr_arr_all['parse_name'] = name;
                    attr_arr_all['name'] = '';
                    attr_arr_all['value'] = '';

                    attr_arr_all['content'] = '<span plugins="checkboxs"  title="'+attr_arr_all['title']+'">';
                    var dot_name ='', dot_value = '';
                    p5.replace(preg_group, function(parse_group) {
                        var is_new=false,option = new Object();
                        parse_group.replace(preg_attr, function(str0,k,val) {
                            if(k=='name')
                            {
                                if(val=='NEWFIELD')
                                {
                                    is_new=true;
                                    fields++;
                                    val = 'data_'+fields;
                                }

                                attr_arr_all['name'] += dot_name + val;
                                dot_name = ',';

                            }
                            else if(k=='value')
                            {
                                attr_arr_all['value'] += dot_value + val;
                                dot_value = ',';

                            }
                            option[k] = val;
                        });

                        if(!attr_arr_all['options']) attr_arr_all['options'] = new Array();
                        attr_arr_all['options'].push(option);
                        if(!option['checked']) option['checked'] = '';
                        var checked = option['checked'] ? 'checked="checked"' : '';
                        attr_arr_all['content'] +='<input type="checkbox" name="'+option['name']+'" value="'+option['value']+'" fieldname="' + attr_arr_all['fieldname'] + option['fieldname'] + '" fieldflow="' + attr_arr_all['fieldflow'] + '" '+checked+'/>'+option['value']+'&nbsp;';

                        if(is_new)
                        {
                            var arr = new Object();
                            arr['name'] = option['name'];
                            arr['plugins'] = attr_arr_all['plugins'];
                            arr['fieldname'] = attr_arr_all['fieldname'] + option['fieldname'];
                            arr['fieldflow'] = attr_arr_all['fieldflow'];
                            add_fields[option['name']] = arr;
                        }

                    });
                    attr_arr_all['content'] += '</span>';

                    //parse
                    template = template.replace(plugin,attr_arr_all['content']);
                    template_parse = template_parse.replace(plugin,'{'+name+'}');
                    template_parse = template_parse.replace('{|-','');
                    template_parse = template_parse.replace('-|}','');
                    template_data[pno] = attr_arr_all;
                    checkboxs++;

                }else if(name)
                {
                    if(tag =='radios') /*单选组  一个字段*/
                    {
                        plugin = p0;
                        plugin = plugin.replace('|-','');
                        plugin = plugin.replace('-|','');
                        attr_arr_all['value'] = '';
                        attr_arr_all['content'] = '<span plugins="radios" name="'+attr_arr_all['name']+'" title="'+attr_arr_all['title']+'">';
                        var dot='';
                        p5.replace(preg_group, function(parse_group) {
                            var option = new Object();
                            parse_group.replace(preg_attr, function(str0,k,val) {
                                if(k=='value')
                                {
                                    attr_arr_all['value'] += dot + val;
                                    dot = ',';
                                }
                                option[k] = val;
                            });
                            option['name'] = attr_arr_all['name'];
                            if(!attr_arr_all['options']) attr_arr_all['options'] = new Array();
                            attr_arr_all['options'].push(option);
                            if(!option['checked']) option['checked'] = '';
                            var checked = option['checked'] ? 'checked="checked"' : '';
                            attr_arr_all['content'] +='<input type="radio" name="'+attr_arr_all['name']+'" value="'+option['value']+'"  '+checked+'/>'+option['value']+'&nbsp;';

                        });
                        attr_arr_all['content'] += '</span>';

                    }else
                    {
                        attr_arr_all['content'] = is_new ? plugin.replace(/NEWFIELD/,name) : plugin;
                    }
                    //attr_arr_all['itemid'] = fields;
                    //attr_arr_all['tag'] = tag;
                    template = template.replace(plugin,attr_arr_all['content']);
                    template_parse = template_parse.replace(plugin,'{'+name+'}');
                    template_parse = template_parse.replace('{|-','');
                    template_parse = template_parse.replace('-|}','');
                    if(is_new)
                    {
                        var arr = new Object();
                        arr['name'] = name;
                        arr['plugins'] = attr_arr_all['plugins'];
                        arr['title'] = attr_arr_all['title'];
                        arr['orgtype'] = attr_arr_all['orgtype'];
                        arr['fieldname'] = attr_arr_all['fieldname'];
                        arr['fieldflow'] = attr_arr_all['fieldflow'];
                        add_fields[arr['name']] = arr;
                    }
                    template_data[pno] = attr_arr_all;


                }
                pno++;
            })
            var view = template.replace(/{\|-/g,'');
            view = view.replace(/-\|}/g,'');
            var parse_form = new Object({
                'fields':fields,//总字段数
                'template':template,//完整html
                'parse':view,
                'data':template_data,//控件属性
                'add_fields':add_fields//新增控件
            });
            return JSON.stringify(parse_form);
        },
        /*type  =  save 保存设计 versions 保存版本  close关闭 */
        fnCheckForm : function ( type ) {
            if(formEditor.queryCommandState( 'source' ))
                formEditor.execCommand('source');//切换到编辑模式才提交，否则有bug

            if(formEditor.hasContents()){
                formEditor.sync();/*同步内容*/

                //--------------以下仅参考-----------------------------------------------------------------------------------------------------
                var type_value='',formid=0,fields=$("#fields").val(),formeditor='';

                if( typeof type!=='undefined' ){
                    type_value = type;
                }
                //获取表单设计器里的内容
                formeditor=formEditor.getContent();
                //解析表单设计器控件
                var parse_form = this.parse_form(formeditor,fields);
                //alert(parse_form);
                //异步提交数据
                $.ajax({
                    type: 'POST',
                    url : '${ctx}/config/form/processor',
                    //dataType : 'json',
                    data : {'type' : type_value,'formid':'${form.id}','parse_form':parse_form},
                    success : function(data){
                        if(data == true) {
                            alert('表单保存成功');
                            window.location.href='${ctx}/config/form';
                        } else {
                            alert('表单保存失败');
                        }
                    }
                });

            } else {
                alert('表单内容不能为空！')
                $('#submitbtn').button('reset');
                return false;
            }
        } ,
        /*预览表单*/
        fnReview : function (){
            if(formEditor.queryCommandState( 'source' ))
                formEditor.execCommand('source');/*切换到编辑模式才提交，否则部分浏览器有bug*/

            if(formEditor.hasContents()){
                formEditor.sync();       /*同步内容*/

                alert("你点击了预览,请自行处理....");
                return false;
                //--------------以下仅参考-------------------------------------------------------------------


                /*设计form的target 然后提交至一个新的窗口进行预览*/
                document.saveform.target="mywin";
                window.open('','mywin',"menubar=0,toolbar=0,status=0,resizable=1,left=0,top=0,scrollbars=1,width=" +(screen.availWidth-10) + ",height=" + (screen.availHeight-50) + "\"");

                document.saveform.action="";
                document.saveform.submit(); //提交表单
            } else {
                alert('表单内容不能为空！');
                return false;
            }
        }
    };

</script>
<!-- script end -->
</body>
</html>
